package net.ealden.model;

public class PagingDetail {
	public static final int DEFAULT_FIRST_RESULT = -1;
	public static final int DEFAULT_ITEMS_PER_PAGE = 25;
	
	private int firstResult = DEFAULT_FIRST_RESULT;
	private int maxResults = DEFAULT_ITEMS_PER_PAGE;
	private int pageNumber;
	private boolean isSortAscending;
	private String sortColumn;
	
	public int getFirstResult() {
		if (DEFAULT_FIRST_RESULT < firstResult) {
			return firstResult;
		} else if (pageNumber == 0) {
			return 0;
		}
		
		return (pageNumber - 1) * maxResults;
	}

	public int getMaxResults() {
		return maxResults;
	}

	public int getPageNumber() {
		return pageNumber;
	}

	public String getSortColumn() {
		return sortColumn;
	}

	public boolean isSortAscending() {
		return isSortAscending;
	}

	public void setFirstResult(int firstResult) {
		this.firstResult = firstResult;
	}

	public void setMaxResults(int maxResults) {
		this.maxResults = maxResults;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public void setSortAscending(boolean isSortAscending) {
		this.isSortAscending = isSortAscending;
	}

	public void setSortColumn(String sortColumn) {
		this.sortColumn = sortColumn;
	}
}
